package com.lhy.tool.autoconfigation;

import com.lhy.tool.database.converter.db2.DB2ColumnTypeMapping;
import com.lhy.tool.database.converter.mysql.MysqlColumnTypeMapping;
import com.lhy.tool.database.converter.oracle.OracleColumnTypeMapping;
import com.lhy.tool.database.converter.postgresql.PostgreSqlColumnTypeMapping;
import com.lhy.tool.database.converter.sqlserver.SqlServerColumnTypeMapping;
import com.lhy.tool.database.table.impl.*;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({GeneratorProperties.class})
public class GeneratorDataBaseAutoConfiguration {


    @Configuration
    public static class DataBaseMetaDataAutoConfiguration {

        @Bean
        @ConditionalOnMissingBean
        public MysqlMetaDataProcessor mysqlDbMetaDataProcessor() {
            return new MysqlMetaDataProcessor();
        }

        @Bean
        @ConditionalOnMissingBean
        public OracleMetaDataProcessor oracleMetaDataProcessor() {
            return new OracleMetaDataProcessor();
        }

        @Bean
        @ConditionalOnMissingBean
        public PostgreSqlMetaDataProcessor postgreSqlMetaDataProcessor() {
            return new PostgreSqlMetaDataProcessor();
        }

        @Bean
        @ConditionalOnMissingBean
        public SqlServerMetaDataProcessor sqlServerMetaDataProcessor() {
            return new SqlServerMetaDataProcessor();
        }

        @Bean
        @ConditionalOnMissingBean
        public DB2MetaDataProcessor db2MetaDataProcessor() {
            return new DB2MetaDataProcessor();
        }
    }


    @Configuration
    public static class DataBaseColumnTypeMappingAutoConfiguration {

        @Bean
        @ConditionalOnMissingBean
        public MysqlColumnTypeMapping mysqlColumnTypeMapping() {
            return new MysqlColumnTypeMapping();
        }

        @Bean
        @ConditionalOnMissingBean
        public OracleColumnTypeMapping oracleColumnTypeMapping() {
            return new OracleColumnTypeMapping();
        }

        @Bean
        @ConditionalOnMissingBean
        public PostgreSqlColumnTypeMapping postgreSqlColumnTypeMapping() {
            return new PostgreSqlColumnTypeMapping();
        }

        @Bean
        @ConditionalOnMissingBean
        public SqlServerColumnTypeMapping sqlServerColumnTypeMapping() {
            return new SqlServerColumnTypeMapping();
        }

        @Bean
        @ConditionalOnMissingBean
        public DB2ColumnTypeMapping db2ColumnTypeMapping() {
            return new DB2ColumnTypeMapping();
        }

    }


}
